<?php
/**
 * ClassName: 仓库历史价格处理器
 * @auditor:leijunxiang
 * @time 2025/4/11 9:04
 */

namespace app\modelOperate\freightForward;

use app\modelOperate\ModelOpeBase;

class WarehousePriceHistoryOpe extends ModelOpeBase
{
    /**
     * 查询详情数据(详情id,开始时间,结束时间,页数,条数)
     * @return array
     */
    public function selectDataWithPagination($detailId, $startTime, $endTime, $page, $limit)
    {
        $query = $this->getDb()
            ->where('detailId', $detailId)
            ->whereBetween('time', [$startTime, $endTime])
            ->page($page, $limit)
            ->order('time', 'desc');
        $data = $query->select()->toArray();
        return $data;
    }
    /**
     * 查询详情数据(详情id,开始时间,结束时间)
     * @return array
     */
    public function selectData($detailId, $startTime, $endTime)
    {
        $query = $this->getDb()
            ->where('detailId', $detailId)
            ->whereBetween('time', [$startTime, $endTime])
            ->order('time', 'asc');
        $data = $query->select()->toArray();
        return $data;
    }

    /**
     * 查询总数(详情id,开始时间,结束时间)
     */
    public function selectCount($detailId, $startTime, $endTime)
    {
        $query = $this->getDb()
            ->where('detailId', $detailId)
            ->whereBetween('time', [$startTime, $endTime]);
        $count = $query->count();
        return $count;
    }
}